package com.usian.controller;

import com.usian.feign.SearchItemFeign;
import com.usian.pojo.SearchItem;
import com.usian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/frontend/searchItem")
public class SearchItemController {

    @Autowired
    private SearchItemFeign searchItemFeign;

    @PostMapping("/importAll")
    public Result importAll(){
        searchItemFeign.importAll();
        return Result.ok();
    }

    @PostMapping("/list")
    public List<SearchItem> list(String q, @RequestParam(defaultValue = "1") Long page, @RequestParam(defaultValue = "20") Integer pageSize){
        List<SearchItem> list =searchItemFeign.list(q,page,pageSize);
        return list;
    }
}
